import { menu } from "../../decorator";

const { ccclass, property } = cc._decorator;

@ccclass
@menu(__filename)
export default class angleAction extends cc.Component {
    @property({ tooltip: '逆时针' })
    reverse = false;

    @property({ type: cc.Float, tooltip: '速度' })
    speed = 10;

    onEnable() {
        this.node.angle = 0;
    }

    update(dt) {
        if (this.reverse) {
            this.node.angle += this.speed * dt;
        } else {
            this.node.angle -= this.speed * dt;
        }

        if (this.node.angle >= 360 || this.node.angle <= -360) {
            this.node.angle = this.node.angle % 360;
        }
    }
}